package top.tagao.m03_beHavioralPatterns.b_03_state.new_way;

import top.tagao.m03_beHavioralPatterns.b_03_state.Result;
import top.tagao.m03_beHavioralPatterns.b_03_state.Status;
import top.tagao.m03_beHavioralPatterns.b_03_state.new_way.event.*;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 文本类
 * @author Viktor_Liu
 * @Date 2022/8/13 19:33
 */
public  class StateHandler {
    private Map<Enum<Status>, State> stateMap = new ConcurrentHashMap<Enum<Status>, State>();
    private State status;
    public StateHandler() {
        // 待审核
        stateMap.put(Status.Check, new CheckState());
        // 编辑中
        stateMap.put(Status.Editing, new EditingState());
//        stateMap.put(Status.Close, new CloseState());     // 已关闭
//        stateMap.put(Status.Doing, new DoingState());     // 活动中
//        stateMap.put(Status.Open, new OpenState());       // 已开启
//        stateMap.put(Status.Pass, new PassState());       // 审核通过
//        stateMap.put(Status.Refuse, new RefuseState());   // 审核拒绝
    }

    public void setState(Enum<Status> currentStatus){
        this.status  = stateMap.get(currentStatus);
    }


    public Result arraignment(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.arraignment(activityId, currentStatus);
    }
    public Result checkPass(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.checkPass(activityId, currentStatus);
    }

    public Result checkRefuse(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.checkRefuse(activityId, currentStatus);
    }

    public Result checkRevoke(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.checkRevoke(activityId, currentStatus);
    }

    public Result close(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.close(activityId, currentStatus);
    }

    public Result open(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.open(activityId, currentStatus);
    }

    public Result doing(String activityId, Enum<Status> currentStatus) {
        setState(currentStatus);
        return status.doing(activityId, currentStatus);
    }



}


